/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#include "ServerChangeScene.h"

#include "SceneObject.h"

#include "GlobalVariables.h"
#include "NetManager.h"


namespace PQClient
{

	ServerChangeScene::ServerChangeScene() : GameScene(Scene_ServerChange)
	{
		setState(Server_Change_Disconnect);
	}

	void ServerChangeScene::loadScene()
	{
		_sceneObject->getRenderProperty().setBackground(Ogre::ColourValue(0,1,1));

	}

	void ServerChangeScene::update(float deltaT)
	{
		GameScene::update(deltaT);
		RunningState state=getState();
		switch(state){
		case Server_Change_Disconnect:
			connect();
			break;
		case Server_Change_Connect_Success:
			//SendCGConnectMsg();
			break;
		case Server_Change_Sending_Connect:
			break;
		case Server_Change_Receive_Connect_Success:
			//ChangeToEnterGameProdure();
			break;
		case Server_Change_Receive_Connect_Fail:
			break;
		default:
			break;
		}
	
	}

	void ServerChangeScene::connect()
	{
		std::string ip=Globals.getString(String_Server_IP);
		int port=Globals.getInt32(Int32_Server_Port);
		NetManager::getSingleton().connect(ip,port);
		setState(Server_Change_Connecting);
	}
}
